/**
 * 
 */
package com.mevoy.async.factory;

import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.io.ClassPathResource;


/**
 * @author diegoicosta
 * 
 */
public class MevoyAsyncFactory {
	private static final MevoyAsyncFactory INSTANCE = new MevoyAsyncFactory();
	private GenericApplicationContext ctx = null;

	private MevoyAsyncFactory() {
		 ctx = new GenericApplicationContext();
		 XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(ctx);
		 xmlReader.loadBeanDefinitions(new ClassPathResource("mevoyasync-context.xml"));
		 ctx.refresh();
	}

	public Object getBean(String beanName) {
		assert (ctx != null);
		Object obj = ctx.getBean(beanName);
		
		return obj;
	}

    public static MevoyAsyncFactory getInstance() {
        return INSTANCE;
    }
	
}
